package aplicacion;

import javax.swing.*;

import java.awt.GridLayout;

@SuppressWarnings("serial")
public class MenuPrincipal extends JFrame {
	private		MenuCliente		menuCliente;
	private		MenuViaje		menuViaje;
	private		MenuPaquete		menuPaquete;
	private 	JTabbedPane panelPrincipal;
	
	public MenuPrincipal() {
		setSize(800, 600);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		getContentPane().setLayout(new GridLayout(1, 0, 0, 0));
		
		ImageIcon iconCliente = createImageIcon("imagenes/cliente.png", "Clientes");
		ImageIcon iconViajes = createImageIcon("imagenes/viaje.png", "Viajes");
		ImageIcon iconPaquetes = createImageIcon("imagenes/paquete_viaje.png", "Viajes");
		menuCliente = new MenuCliente();
		menuViaje = new MenuViaje();
		menuPaquete = new MenuPaquete();
		
		panelPrincipal = new JTabbedPane(JTabbedPane.TOP);
		panelPrincipal.addTab("Clientes", iconCliente, menuCliente.getPanel());
		panelPrincipal.addTab("Paquetes", iconPaquetes, menuPaquete.getPanel());
		panelPrincipal.addTab("Viajes", iconViajes, menuViaje.getPanel());
		getContentPane().add(panelPrincipal);
		setVisible(true);
	}
	
	/** Returns an ImageIcon, or null if the path was invalid. */
	protected ImageIcon createImageIcon(String path,
	                                           String description) {
	    java.net.URL imgURL = getClass().getResource(path);
	    if (imgURL != null) {
	        return new ImageIcon(imgURL, description);
	    } else {
	        System.err.println("Couldn't find file: " + path);
	        return null;
	    }
	}
	
}
